<?php
namespace Api\Controller;

use Services\Fenxiao\FenxiaoService;

class FenxiaoController extends AuthController
{
    /** @var FenxiaoService $fenxiaoService */
    private $fenxiaoService;

    public function _initialize()
    {
        parent::_initialize();
        $this->fenxiaoService = new FenxiaoService();
    }

    /**
     * 绑定分销关系
     * @return void
     */
    public function bind()
    {
        $parentUserId = I('post.parent_user_id');
        $userId = $this->getUserId();

        $this->fenxiaoService->setParams([
            'parent_user_id' => $parentUserId,
            'user_id' => $userId
        ]);
        $this->returnSuccess($this->fenxiaoService->bind());
    }

    /**
     * 获取下级用户列表
     * @return void
     */
    public function getSubordinateList()
    {
        $this->fenxiaoService->setParams([
            'user_id' => $this->getUserId(),
            'page' => I('get.page'),
            'page_limit' => I('get.page_limit'),
            'type' => I('get.type'),
        ]);
        $users = $this->fenxiaoService->getSubordinateList();
        $this->returnSuccess($users);
    }
}

?>
